Skip to content

New check: eraseIteratorOutOfBounds#5913

Merged
orbitcowboy merged 15 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_eraseEnd
Feb 4, 2024
Merged

New check: eraseIteratorOutOfBounds#5913
orbitcowboy merged 15 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_eraseEnd

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

@chrchr-github
Copy link
Copy Markdown
Collaborator Author

chrchr-github commented Jan 24, 2024

Why would we set the ITERATOR_END value for end() - 1? Or is it meant to be interpreted together with the intvalue?

@chrchr-github chrchr-github marked this pull request as ready for review January 29, 2024 13:19
Comment thread lib/checkstl.cpp Outdated
Comment thread test/teststl.cpp
@pfultz2
Copy link
Copy Markdown
Contributor

pfultz2 commented Jan 29, 2024

Why would we set the ITERATOR_END value for end() - 1?

The ITERATOR_END is the position from the end. So end() - 1 should have intvalue of -1. We can also check if the end iterator is out of range if its less than -size().

Comment thread lib/checkstl.cpp Outdated
@chrchr-github chrchr-github changed the title New check: erasing end() New check: eraseIteratorOutOfBounds Jan 29, 2024
Comment thread lib/checkstl.cpp Outdated
Comment thread lib/checkstl.cpp
Comment thread lib/checkstl.cpp Outdated
Comment thread lib/checkstl.h
Comment thread lib/checkstl.cpp Outdated
Comment thread lib/checkstl.cpp
Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@orbitcowboy orbitcowboy merged commit faaabb1 into cppcheck-opensource:main Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants